#ifndef CVCODEBOOK_H
#define CVCODEBOOK_H

#define CHANNELS 3

#ifndef CXCORE_H
#define CXCORE_H
#include "cxcore.h"
#endif

#ifndef HIGHGUI_H
#define HIGHGUI_H
#include "highgui.h"
#endif

#ifndef CV_H
#define CV_H
#include "cv.h"
using namespace cv;
#endif

#ifndef IOSTREAM_H
#define IOSTREAM_H
#include <iostream>
using namespace std;
#endif

struct CvCodeWord{
	uchar learnHigh[CHANNELS];
	uchar learnLow[CHANNELS];
	uchar max[CHANNELS];
	uchar min[CHANNELS];
	int tLastUpdate;
	int stale;
};

class CvCodeBook{
public:
	CvCodeWord **m_codeWords;
	int m_numEntries;
	int m_time;
public:
	CvCodeBook();
	~CvCodeBook();
	int cvUpdateCodeBook(uchar *pixel, unsigned int *cbBounds, int numChannels);
	int cvClearStaleEntries();
	uchar cvBackgroundDiff(uchar *pixel, int *minMod, int *maxMod, int numChannels);
	void cvFindConnectedComponents(Mat mask, int poly1Hull0, float perimScale, int *num, CvRect *boxs, CvPoint *centers);
};
#endif